import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: () => import('@/views/login.vue')
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: () => import('@/views/error-page/404.vue')
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: () => import('@//views/error-page/403.vue')
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: () => import('@/views/error-page/500.vue')
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: () => import('@/views/form/article-publish/preview.vue')
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('@/views/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        { path: 'home', title: {i18n: 'home'}, name: 'home_index', component: () => import('@/views/home/home.vue') },
        { path: 'ownspace', title: '个人中心', name: 'ownspace_index', component: () => import('@/views/own-space/own-space.vue') },
        { path: 'order/:order_id', title: '订单详情', name: 'order-info', component: () => import('@/views/advanced-router/component/order-info.vue') }, // 用于展示动态路由
        { path: 'shopping', title: '购物详情', name: 'shopping', component: () => import('@/views/advanced-router/component/shopping-info.vue') }, // 用于展示带参路由
        { path: 'message', title: '消息中心', name: 'message_index', component: () => import('@/views/message/message.vue') },
        { path: 'alert-add', title: '报告故障', name: 'event-add', component: () => import('@/views/alert/add') },
        { path: 'alert-check/:id', title: '检测故障', name: 'event-check', component: () => import('@/views/alert/check') },
        { path: 'alert-finish/:id', title: '处理故障', name: 'event-finish', component: () => import('@/views/alert/finish') },
        { path: 'search-result/:searchedWord', title: '搜索结果', name: 'search-result', component: () => import('@/views/home/search-result') },
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/management',
        icon: 'clipboard',
        name: 'management',
        title: '设备常规管理',
        component: Main,
        children: [
            { path: 'management-device', title: '设备管理', name: 'management-device', component: () => import('@/views/management/device.vue') },
            { path: 'management-type', title: '种类管理', name: 'management-type', component: () => import('@/views/management/type.vue') },
            { path: 'management-tag', title: '标签管理', name: 'management-tag', component: () => import('@/views/management/tag.vue') },
        ]
    },
    {
        path: '/location',
        icon: 'location',
        name: 'location',
        title: '设备定位',
        component: Main,
        children: [
            { path: 'location-realtime', title: '实时定位', name: 'location-realtime', component: () => import('@/views/location/realtime.vue') },
            { path: 'location-area', title: '电子围栏配置', name: 'location-area', component: () => import('@/views/location/area.vue') },
        ]
    },
    {
        path: '/data',
        icon: 'battery-charging',
        name: 'data',
        title: '设备数据采集',
        component: Main,
        children: [
            { path: 'data-hospital', title: '医疗设备', name: 'data-hospital', component: () => import('@/views/analysis/hospital.vue') },
            { path: 'data-research', title: '科研设备', name: 'data-research', component: () => import('@/views/analysis/hospital.vue') },
        ]
    },
    {
        path: '/efficiency',
        icon: 'stats-bars',
        name: 'efficiency',
        title: '设备效能分析',
        component: Main,
        children: [
            { path: 'efficiency-day', title: '日视图', name: 'efficiency-day', component: () => import('@/views/efficiency/day.vue') },
            { path: 'efficiency-hour', title: '小时视图', name: 'efficiency-hour', component: () => import('@/views/efficiency/hour.vue') },
            { path: 'efficiency-second', title: '秒视图', name: 'efficiency-second', component: () => import('@/views/efficiency/second.vue') },
        ]
    },
    {
        path: '/cost',
        icon: 'outlet',
        name: 'cost',
        title: '设备计费分析',
        component: Main,
        children: [
            { path: 'cost-record', title: '计费历史查询', name: 'cost-record', component: () => import('@/views/cost/record.vue') },
            { path: 'cost-rule', title: '计费规则配置', name: 'cost-rule', component: () => import('@/views/cost/rule.vue') },
        ]
    },
    {
        path: '/alert',
        icon: 'android-warning',
        name: 'alert',
        title: '设备故障管理',
        component: Main,
        children: [
            { path: 'alert-list', title: '故障列表', name: 'alert-list', component: () => import('@/views/alert/list.vue') },
            { path: 'alert-history', title: '历史故障', name: 'alert-history', component: () => import('@/views/alert/history.vue') },
        ]
    },
    {
        path: '/access',
        icon: 'gear-a',
        name: 'access',
        title: '权限管理',
        component: Main,
        children: [
            { path: 'access-role', title: '角色管理', name: 'access-role', component: () => import('@/views/access/role.vue') },
            { path: 'access-user', title: '用户管理', name: 'access-user', component: () => import('@/views/access/user.vue') }
        ]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
